<!--<div class="item-tab-con  game-user-up" style="background: rgb(255, 255, 255);min-height:700px;" >

    
</div>-->

<link rel="stylesheet" type="text/css" href="/public/3rd/xcconfirm/xcConfirm.css"/>
<script src="/public/3rd/xcconfirm/xcConfirm.js" type="text/javascript" charset="utf-8"></script>

                
<style>
    .charge_member_form .row{
        width:100%;
        padding:10px 0;
    }
    .col-md-2{
        font-size:16px;
    }
    .charge_member_form input[type='text']{
        width:200px;
        
    }
    .charge_member_form input[type='password']{
        width:200px;
        
    }
</style>
<div class="container charge_member_form" style="width:600px;float:left;margin-left:50px;margin-top:50px;">
<form method="post" id="charge_form" action="{:U('Agent/ChargeMember/charge')}" >
    <div class="row">
        <div class="col-md-2">
        游戏名称
        </div>
        <div class="col-md-10">
            <select id="choose_game" name="app_id" style="width:200px;">
                {$game_select_txt}
            </select>
        </div>
    </div>
    <div class="row">
        <div class="col-md-2">
        玩家账号
        </div>
        <div class="col-md-10">
            <select name="mem_id" style="width:200px;">
                {$member_select_txt}
            </select>
        </div>
    </div>
    <div class="row">
        <div class="col-md-2">
        充值金额
        </div>
        <div class="col-md-10">
        <input type="text" name="amount" id="amount" maxlength="5" class="form-control" autocomplete="off" />
        </div>
    </div>
     
    <div class="row">
        <div class="col-md-2" id='benefit_type_name'>
            折扣
        </div>
        <div class="col-md-10">
            <span id="rate"></span>
        </div>
    </div>
    <div class="row">
        <div class="col-md-2">
            支付金额
        </div>
        <div class="col-md-10">
            <span id="pay_amount"></span>
        </div>
    </div>
    <div class="row getcoinrow" style='display:none;'>
        <div class="col-md-2">
            获得{:C(CURRENCY_NAME)}
        </div>
        <div class="col-md-10">
            <span id="getcoin"></span>
        </div>
    </div> 
<!--    <div class="row">
        <div class="col-md-2">
        获得{:C(CURRENCY_NAME)}
        </div>
        <div class="col-md-10">
        <input type="text" name="getgold" id="getgold" maxlength="5" class="form-control" autocomplete="off" />
        </div>
    </div>-->
    <div class="row">
        <div class="col-md-2">
            支付密码
        </div>
        <div class="col-md-10">
            <input id="paypwd" name="paypwd" class="form-control" type="password" autocomplete="off" />
        </div>
    </div>
    <div class="row">
        <div class="col-md-2">
        
        </div>
        <div class="col-md-10">
            <button  class="btn btn-success btn_charge" style="margin-top:30px;">立即支付</button>
        </div>
    </div>
</form>
</div>

<a href="#confirm_order" id="order_confirm_btn" class="default_popup" style="display:none;">确认订单</a>
<script>
    var agent_rate=0;
    var amount=0;
    var pay_amount=0;
    var getcoin=0;
    var benefit_type=0;
    $("#amount").keyup(function(){
        update_view_discount();
        
//        benefit_type=$("select[name='app_id']").find("option:selected").attr("data-benefit-type");
//        if(benefit_type=='2'){
//            update_view_rebate();
//        }else if(benefit_type=='1'){
//            update_view_discount();
//        }else if(benefit_type==''){
//            update_view_discount();
//        }
    });
            
    $("#choose_game").change(function(){
        var ag_id=$(this).find("option:selected").attr("data-agid");
        var app_id=$(this).val();
        benefit_type=$(this).find("option:selected").attr("data-benefit-type");
//        alert(ag_id+" "+benefit_type);
        agent_rate=$(this).find("option:selected").attr("data-agent-rate");
        $("#rate").text(agent_rate);
        
        update_view_discount();
        
//        if(benefit_type=='2'){
//            update_view_rebate();
//        }else if(benefit_type=='1'){            
//            update_view_discount();
//        }else if(benefit_type==''){            
//            update_view_discount();
//        }
    });
    
    function update_view_rebate(){                    
        amount=$("#amount").val();
        pay_amount=parseFloat(amount);
        $("#pay_amount").text(pay_amount);
        agent_rate=$("select[name='app_id']").find("option:selected").attr("data-agent-rate");
        agent_rate=parseFloat(agent_rate);
        getcoin=parseFloat(pay_amount+pay_amount*agent_rate).toFixed(2);        
        $("#getcoin").text(getcoin);
        
        $("#benefit_type_name").text("返利");
        $(".getcoinrow").show();
    }
    function update_view_discount(){
        amount=$("#amount").val();
        amount=parseFloat(amount).toFixed(2);
        agent_rate=$("select[name='app_id']").find("option:selected").attr("data-agent-rate");
        agent_rate=parseFloat(agent_rate);
        pay_amount=(amount*agent_rate).toFixed(2);
        $("#pay_amount").text(pay_amount);
        
        $("#benefit_type_name").text("折扣");
        $(".getcoinrow").hide();
    }
    
    $("#charge_form").submit(function(e){
        e.preventDefault();
        $.post("{:U('Agent/ChargeMember/charge')}",$("#charge_form").serialize(),function(data){
            if(data.error==='0'){
                yxalert(data.msg);
                setTimeout(function(){location.reload();},2000);
                
            }else{
                yxalert(data.msg);
            }
        });
    });
</script>